<html>
<head><meta charset="utf-8"><title>Interface files · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Interface.20files.html">Interface files</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="161394249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Interface%20files/near/161394249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Interface.20files.html#161394249">(Mar 21 2019 at 20:47)</a>:</h4>
<p>By the way, I was thinking about how we could provide std lib support if <a href="https://github.com/rust-analyzer/rust-analyzer/issues/1007" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/issues/1007">rust-analyzer#1007</a> was implemented (a bit prematurely, I've got to admit ;) ) and I had an idea: It should be possible to take a crate, parse and macroexpand it, and then basically write a big <code>.rs</code> file containing only its public API, with docstrings etc. but without bodies or private items. So it would basically be a valid rust file syntactically and provide the same public interface as the original crate, but it wouldn't typecheck or be compilable. But we'd be able to load it instead of the original crate, hopefully a lot faster, and maybe even e.g. bundle it with the WASM version... </p>
<p>Of course a binary format would be even faster and smaller, but we'd also need to worry about compatibility, and implement serialization etc., whereas this seems like it'd actually be relatively easy to do...</p>



<a name="161420790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Interface%20files/near/161420790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Interface.20files.html#161420790">(Mar 22 2019 at 05:06)</a>:</h4>
<p>Heh, Swift works like this: their intermediate language, SIL, is textual and is parsed by the same parser that deals with source</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>